﻿@page
@using Microsoft.AspNetCore.Http;
@model IndexModel
@{
    ViewData["Title"] = "Home page";
    var user = HttpContext.Session.GetString("User");
}

<div class="timeline-comment-box">
    <div class="row">
        <form action="Index/?handler=Upload" style="width: 100%;"
              enctype="multipart/form-data" onsubmit="AJAXSubmit(this);return false;"
              method="post">
            @Html.AntiForgeryToken()
            @if (user == "新郎" || user == "新娘")
            {
                <div class="input-group" style="padding-bottom: 10px;">
                    <input id="fileInput" name="FileUpload.FormFiles" type="file" multiple />
                </div>
            }
            <div class="input-group">
                <input type="text" style="display:none" id="userInput" name="FileUpload.User" value="@user" />
                <input type="text" class="form-control rounded-corner" id="messageInput" name="FileUpload.Message" />
                <span class="input-group-btn p-l-10">
                    <button class="btn btn-primary rounded-corner" type="submit" id="sendButton">发送消息</button>
                </span>
            </div>
        </form>
    </div>
</div>

<!-- begin timeline -->
<ul id="messagesList" class="timeline">
    @foreach (var msg in Model.Messages)
    {
        <li>
            <div class="timeline-time">
                <span class="time">@msg.Time</span>
            </div>
            <div class="timeline-icon">
                <a href="javascript:;">&nbsp;</a>
            </div>
            <div class="timeline-body">
                <div class="timeline-content">
                    @if (msg.Images != null)
                    {
                        @foreach (var img in msg.Images)
                        {
                            <a href="@img"><img src="@img?width=960" /></a>
                        }
                    }
                    <p>
                        @msg.User：@msg.Message
                    </p>
                </div>
            </div>
        </li>
    }
</ul>
<div class="text-center">
    <input type="text" style="display:none" id="minIdInput" value="@Model.MinId" />
    <a href="javascript:;" onclick="more()" id="moreButton" style="@(Model.MinId > 1?"":"display:none")" class="btn btn-primary">加载更多</a>   
</div>
<!-- end timeline -->
<script src="~/lib/signalr/dist/browser/signalr.min.js"></script>
<script src="~/js/chat.js"></script>
@section Scripts {
    <script src="~/js/site.js"></script>
}
